const fs = require('fs');
const getHtml = async (ctx:any) => {
    let html = await render('index.html');
    ctx.body = html;
}

/**
 * @param page 文件名称
 * @returns Promise
 */
 function render(page:any){
    return new Promise((resolve,reject)=>{
        let distUrl = `../dist/${page}`;
        fs.readFile(distUrl, "binary", (err:any, data:any)=>{
            if(err){
                reject(err);
            }else{
                resolve(data);
            }
        })
    })
}

module.exports = {
    getHtml
}